package com.wcl.hencodertest.batteryMeterView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * @项目名： HenCoderTest
 * @包名： com.wcl.hencodertest.test07_drawing
 * @文件名: RotateTestView
 * @创建者: kilin
 * @创建时间: 2020/4/27 17:13
 * @描述： TODO
 */
public class RotateTestView extends View {

    private RectDrawable drawable;

    public RotateTestView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    {
        drawable = new RectDrawable();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        super.onDraw(canvas);
//        drawable.setBounds(0,0,getWidth(),getHeight());
//        drawable.draw(canvas);
//        canvas.save();
//        canvas.translate((getWidth() / 2F), (getHeight() / 2F));
//        canvas.rotate(-90);
//        canvas.translate(-(getWidth() / 2F), -(getHeight() / 2F));
        canvas.drawRect(getWidth() / 2F - 50, getHeight() / 2F - 100, getWidth() / 2F + 50, getHeight() / 2F + 100, paint);
        canvas.drawRect(getWidth() / 2F - 20, getHeight() / 2F - 120, getWidth() / 2F + 20, getHeight() / 2F - 100, paint);
//        canvas.restore();
    }
}
